/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;

/**
 *
 * @author josegarcia
 */
public class MainServer {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) throws IOException {
		ArrayList<Request> tasks= new ArrayList<Request>(0);
		ServerSocket serverSocket = null;
		Object lockTasks=new Object();

		Boolean listening = new Boolean(true);

		try {
			serverSocket = new ServerSocket(2222);
		} catch (IOException e) {
			System.err.println("Could not listen on port: 4444.");
			System.exit(-1);
		}
		new ExcecThread(tasks,lockTasks,listening).start();
		while (listening.booleanValue()){
			new ListThread(serverSocket.accept(), tasks, lockTasks).start();
		}

		serverSocket.close();
	}


}
